<extend name="Index:info"/>
<block name="body">
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加用户</strong>
    <a href="javascript:;" class="return" style="display:block;float:right;">返回用户列表</a>
    <script>
      $('.return').click(function(){
        history.go(-1);
      });
    </script>
  </div>

  <div class="body-content">
    <form method="post" class="form-x" action="">
      <div class="form-group">
        <div class="label">
          <label>账号：</label>
        </div>
        <div class="field">
          <input type="text" id="user_name" class="input w50" maxlength="18" minlength="6" name="user_name" onkeyUp="value=value.replace(/[\W]/g,'')" /><span class="if" style="font-size:18px;color:red;"></span>
          <div class="tips"></div>
        </div>
      </div>
      <script>
          $('#user_name').keyup(function (){
              $.ajax({
                async:true,
                type:'post',
                data:{user_name:$('#user_name').val()},
                url:"{:U('user/add_ajax')}",
                success:function(user){
                    if($('#user_name').val() == ''){
                        $('.if').empty();
                    }else if($('#user_name').val().length < 6){
                        $('.if').empty();
                        $('.if').html("请输入6-18位之间的英文字母或数字");
                    }else if(user == 0){
                        $('.if').empty();
                        $('.if').html("账号已存在");
                    }else if(user == 1){
                        $('.if').empty();
                        $('.if').html("<img src=\"__PUBLIC__/home/image/gou_03.gif\" height='20px'>");
                    }
                }
              })
          });
      </script>
      <div class="form-group">
        <div class="label">
          <label>密码：</label>
        </div>
        <div class="field">
          <input type="password" maxlengt="18" minlength="6" id="password" class="input w50" value="" name="password" /><span class="password"></span>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
      <div class="label">
        <label>昵称：</label>
      </div>
      <div class="field">
        <input type="text" class="input w50" value="" name="nickname"/>
        <div class="tips"></div>
      </div>
    </div>
      <div class="form-group">
        <div class="label">
          <label>余额：</label>
        </div>
        <div class="field">
          <input type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " maxlength="10" class="input w50" value="" name="balance" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>积分：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " maxlength="10" value="" name="integral" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>年龄：</label>
        </div>
        <div class="field">
          <input onkeyup="this.value=this.value.replace(/[^\d]/g,'') " maxlength="2" class="input w50" value="20" name="age" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label" >
          <label>性别：</label>
        </div>
        <div class="field" style="font-size:25px;">
        <img src="__PUBLIC__/home/image/nv.gif" class="img-circle" height="25"> <input name="sex" type="radio" value="2" checked>
        <img src="__PUBLIC__/home/image/nan.gif" class="img-circle" height="25"> <input name="sex" type="radio" value="1">
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>地址：</label>
        </div>
        <div class="field">
          <textarea class="input" name="address" value="" style=" height:50px;">管理员账户</textarea>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
<script>
  $('#password').keyup(function (){
    if($('#password').val() == ''){
      $('.password').empty();
    }else if($('#password').val().length<6){
      $('.password').empty();
      $('.password').css('color','red');
      $('.password').css('font-size','18px');
      $('.password').html('密码长度6-18位');
    }else{
      $('.password').empty();
      $('.password').html("<img src=\"__PUBLIC__/home/image/gou_03.gif\" height='20px'>");
    }
  })

</script>
</block>